﻿// Author:					HungNM
// Created:					27-07-2012
// Last Modified:			27-07-2012
//

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Web;
using eProject.Data;

namespace eProject.Business
{
    public class UserHelper
    {
        #region Properties

        public Users User { get; private set; }

	    #endregion

	    #region Singleton Implementation

	    // Readonly properties can only be set in initialization or in a constructor
	    public static readonly UserHelper Instance;
	    // The static constructor is called as soon as the class is loaded into memory
	    static UserHelper() {
		    // If the cart is not in the session, create one and put it there
		    // Otherwise, get it from the session
            if (HttpContext.Current.Session["ASPNETUserHelper"] == null)
            {
			    Instance = new UserHelper();
                HttpContext.Current.Session["ASPNETUserHelper"] = Instance;
		    } else {
                Instance = (UserHelper)HttpContext.Current.Session["ASPNETUserHelper"];
		    }
	    }

	    // A protected constructor ensures that an object can't be created from outside
        protected UserHelper() { }

	    #endregion

	    #region Item Modification Methods

	    public void AddUser(long userId) {
            User = new Users(userId);
	    }
        public void Remove()
        {
            HttpContext.Current.Session["ASPNETUserHelper"] = null;
            User = null;
        }

	    #endregion
    }
}
